package com.iplant.wms.service.po.brm;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;

import java.io.Serializable;


/**
 * 上架详情
 *
 * @author ShrisJava
 */

@DBBasePO(TableName = "brm_sampleprop",  CheckName = {"RuleID,Code","RuleID,Name"},
        Schemas = DBSchemas.WMS,CodeAuto = true,CodePrefix = "BSEP-")
public class BRMSampleProp extends BasePO implements Serializable {
    private static final long serialVersionUID = 1L;

    @DBCondition
    @DBField
    public int RuleID = 0;

    /**
     * 模板代码
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like, ParamName2 = "RuleCodeEQ")
    @DBJoin(name = "Code", tableName = "brm_samplerule", Schemas = DBSchemas.WMS, tableAsName = "r1", MainTableField = "RuleID")
    public String RuleCode = "";

    /**
     * 模板名称
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "brm_samplerule", Schemas = DBSchemas.WMS, tableAsName = "r1", MainTableField = "RuleID")
    public String RuleName = "";


    /**
     * ASN
     */
    @DBCondition
    @DBField
    public int ASNTypeID = 0;

    @DBJoin(name = "Name", tableName = "wms_bill_type", Schemas = DBSchemas.WMS, tableAsName = "bt1", MainTableField = "ASNTypeID")
    public String ASNTypeName = "";

    @DBJoin(name = "Code", tableName = "wms_bill_type", Schemas = DBSchemas.WMS, tableAsName = "bt1", MainTableField = "ASNTypeID")
    public String ASNTypeCode = "";


    /**
     * 批量起始数量
     */
    @DBField
    public int MinNumber = 0;

    /**
     * 批量结束数量
     */
    @DBField
    public int MaxNumber = 0;

    /**
     * 样本数量
     */
    @DBField
    public int SampleNumber = 0;

    @DBField
    public double SampleRate = 0;

    @DBField
    public int SampleMinNumber = 0;

    @JsonProperty("RuleID")
    public int getRuleID() {
        return RuleID;
    }

    public void setRuleID(int ruleID) {
        RuleID = ruleID;
    }

    @JsonProperty("RuleCode")
    public String getRuleCode() {
        return RuleCode;
    }

    public void setRuleCode(String ruleCode) {
        RuleCode = ruleCode;
    }

    @JsonProperty("RuleName")
    public String getRuleName() {
        return RuleName;
    }

    public void setRuleName(String ruleName) {
        RuleName = ruleName;
    }

    @JsonProperty("ASNTypeID")
    public int getASNTypeID() {
        return ASNTypeID;
    }

    public void setASNTypeID(int ASNTypeID) {
        this.ASNTypeID = ASNTypeID;
    }

    @JsonProperty("MinNumber")
    public int getMinNumber() {
        return MinNumber;
    }

    public void setMinNumber(int minNumber) {
        MinNumber = minNumber;
    }

    @JsonProperty("MaxNumber")
    public int getMaxNumber() {
        return MaxNumber;
    }

    public void setMaxNumber(int maxNumber) {
        MaxNumber = maxNumber;
    }

    @JsonProperty("SampleNumber")
    public int getSampleNumber() {
        return SampleNumber;
    }

    public void setSampleNumber(int sampleNumber) {
        SampleNumber = sampleNumber;
    }

    @JsonProperty("SampleRate")
    public double getSampleRate() {
        return SampleRate;
    }

    public void setSampleRate(double sampleRate) {
        SampleRate = sampleRate;
    }

    @JsonProperty("SampleMinNumber")
    public int getSampleMinNumber() {
        return SampleMinNumber;
    }

    public void setSampleMinNumber(int sampleMinNumber) {
        SampleMinNumber = sampleMinNumber;
    }
    @JsonProperty("ASNTypeName")
    public String getASNTypeName() {
        return ASNTypeName;
    }

    public void setASNTypeName(String ASNTypeName) {
        this.ASNTypeName = ASNTypeName;
    }
    @JsonProperty("ASNTypeCode")
    public String getASNTypeCode() {
        return ASNTypeCode;
    }

    public void setASNTypeCode(String ASNTypeCode) {
        this.ASNTypeCode = ASNTypeCode;
    }

    public double CalcSampleNumber(double wMaterialNumber){
        if(SampleRate<=0){
            return SampleNumber;
        }else{
            wMaterialNumber= SampleRate*wMaterialNumber;
            if(wMaterialNumber<SampleMinNumber){
                return SampleMinNumber;
            }else{
                return wMaterialNumber;
            }
        }


    }
}
